home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The X-Philes (2nd Revision)
/
The X-Philes Number 1 (1995).iso
/
xphiles
/
hp48hor1
/
walsh.doc
< prev
next >
Wrap
Text File
|
1995-03-31
|
3KB
|
69 lines
WALSH.DOC -- A step-by-step Voyager tutorial.
By Joseph K. Horn
There is a binary file's Voyager-format MEM image on this disk called
WALSH.MEM. It was created from an HP 48 library created by Brian Walsh.
The name and purpose of his library is NOT DOCUMENTED here, because:
This file is included specifically to show you how easy it is to tear apart
an HP 48 library, completely figure out what it's for and how it was written,
and even surgically remove routines from a library (manually! without TOOLS!),
without having a scrap of documentation for the library itself. And then
write an improved version that's shorter and faster!
(I assume below that DNICKEL is your current directory, and that you're
working from the floppy. If you copied the floppy to hard disk, use the
appropriate pathname below...)
Just run Voyager, LOAD 1 \HORN2\WALSH, then UT 80000. You'll see:
80000: 02B40 ! Library
80005: 0131B ! 4891 nibbles (next RPL at 81320)
8000A: [...] ! Library name: "Util:C Brian Walsh"
80034: 6A0 ! Library number 1696 <-----
80037: 010F2 ! Hash table at 81129 <-----
8003C: 00000 ! No message table
80041: 0105C ! Link table at 8109D <-----
80046: 01024 ! Configuration code at 8106A
Now let's use the library number (6A0), hash address (81129) and link address
(8109D) to EXAMINE HASH 8129 6A0, and you'll see (among other things):
811C0: [...] ! NIP (XLIB 1696 5)
Which means that there is a function in Walsh's library called NIP; it's
XLIB 1696 5. EXAMINE LINK 8109D 6A0 and see (among other things):
810C0: FFD71 ! XLIB 1696 5 at 80E31
So NIP starts at 80E31; we can look at NIP's listing by UT 80E31:
80E31: 02D9D ! Program
80E36: 2361E ; << (XLIB 1792 18)
80E3B: 1FBBD ; SWAP (XLIB 2 271)
80E40: 1FBD8 ; DROP (XLIB 2 272)
80E45: 23639 ; >> (XLIB 1792 19)
80E4A: 0312B ! End Marker
So Brian wrote a program called NIP which is simply << SWAP DROP >>.
If the library is in your HP 48 at the beginning of port 1, you can even
recall this program to the stack by typing #80E31h and running the SYSRCL
program (see IO.DOC on this disk).
Brian's NIP is 15 bytes long. Writing a 2.5-byte version, using the tools
on this disk, is simple:
NIP's purpose is to drop the object in level two. To see if there's a system
routine that does this, type "find : drop" in Voyager. All the routines with
DROP in them will be listed; among them, see "60F9B drop level two object".
That's what we want! Just type << #60F9B SYSEVAL >>, then run PACK to turn
the SYSEVAL into an External, and run STRIP to remove the program delimiters.
The result is a 2.5-byte program (looks like "External") which performs the
same function as NIP in Brian's library.
See also the TOOLS file on this disk, which contains a program called
Extract, which automatically "extracts" a program from a library.
-- Joe Horn